package g;

import java.util.Arrays;

/* compiled from: SegmentedByteString */
public final class x extends h {
    public final transient byte[][] f;
    public final transient int[] g;

    public x(e eVar, int i) {
        int i2;
        super(null);
        b0.b(eVar.b, 0, (long) i);
        v vVar = eVar.a;
        int i3 = 0;
        int i4 = 0;
        int i5 = 0;
        while (i4 < i) {
            i2 = vVar.c;
            int i6 = vVar.b;
            if (i2 != i6) {
                i4 += i2 - i6;
                i5++;
                vVar = vVar.f;
            } else {
                throw new AssertionError("s.limit == s.pos");
            }
        }
        this.f = new byte[i5][];
        this.g = new int[(i5 * 2)];
        v vVar2 = eVar.a;
        int i7 = 0;
        while (i3 < i) {
            byte[][] bArr = this.f;
            bArr[i7] = vVar2.a;
            i5 = vVar2.c;
            i2 = vVar2.b;
            i5 = (i5 - i2) + i3;
            i3 = i5 > i ? i : i5;
            int[] iArr = this.g;
            iArr[i7] = i3;
            iArr[bArr.length + i7] = i2;
            vVar2.d = true;
            i7++;
            vVar2 = vVar2.f;
        }
    }

    public String a() {
        return z().a();
    }

    /* JADX WARNING: Missing block: B:8:0x001d, code skipped:
            if (n(0, r5, 0, p()) != false) goto L_0x0021;
     */
    public boolean equals(java.lang.Object r5) {
        /*
        r4 = this;
        r0 = 1;
        if (r5 != r4) goto L_0x0004;
    L_0x0003:
        return r0;
    L_0x0004:
        r1 = r5 instanceof g.h;
        r2 = 0;
        if (r1 == 0) goto L_0x0020;
    L_0x0009:
        r5 = (g.h) r5;
        r1 = r5.p();
        r3 = r4.p();
        if (r1 != r3) goto L_0x0020;
    L_0x0015:
        r1 = r4.p();
        r5 = r4.n(r2, r5, r2, r1);
        if (r5 == 0) goto L_0x0020;
    L_0x001f:
        goto L_0x0021;
    L_0x0020:
        r0 = 0;
    L_0x0021:
        return r0;
        */
        throw new UnsupportedOperationException("Method not decompiled: g.x.equals(java.lang.Object):boolean");
    }

    public int hashCode() {
        int i = this.b;
        if (i != 0) {
            return i;
        }
        i = this.f.length;
        int i2 = 0;
        int i3 = 0;
        int i4 = 1;
        while (i2 < i) {
            byte[] bArr = this.f[i2];
            int[] iArr = this.g;
            int i5 = iArr[i + i2];
            int i6 = iArr[i2];
            i3 = (i6 - i3) + i5;
            while (i5 < i3) {
                i4 = (i4 * 31) + bArr[i5];
                i5++;
            }
            i2++;
            i3 = i6;
        }
        this.b = i4;
        return i4;
    }

    public byte j(int i) {
        int i2;
        b0.b((long) this.g[this.f.length - 1], (long) i, 1);
        int y = y(i);
        if (y == 0) {
            i2 = 0;
        } else {
            i2 = this.g[y - 1];
        }
        int[] iArr = this.g;
        byte[][] bArr = this.f;
        return bArr[y][(i - i2) + iArr[bArr.length + y]];
    }

    public String k() {
        return z().k();
    }

    public byte[] l() {
        return v();
    }

    public boolean n(int i, h hVar, int i2, int i3) {
        if (i < 0 || i > p() - i3) {
            return false;
        }
        int y = y(i);
        while (i3 > 0) {
            int i4;
            if (y == 0) {
                i4 = 0;
            } else {
                i4 = this.g[y - 1];
            }
            int min = Math.min(i3, ((this.g[y] - i4) + i4) - i);
            int[] iArr = this.g;
            byte[][] bArr = this.f;
            if (!hVar.o(i2, bArr[y], (i - i4) + iArr[bArr.length + y], min)) {
                return false;
            }
            i += min;
            i2 += min;
            i3 -= min;
            y++;
        }
        return true;
    }

    public boolean o(int i, byte[] bArr, int i2, int i3) {
        if (i < 0 || i > p() - i3 || i2 < 0 || i2 > bArr.length - i3) {
            return false;
        }
        int y = y(i);
        while (i3 > 0) {
            int i4;
            if (y == 0) {
                i4 = 0;
            } else {
                i4 = this.g[y - 1];
            }
            int min = Math.min(i3, ((this.g[y] - i4) + i4) - i);
            int[] iArr = this.g;
            byte[][] bArr2 = this.f;
            if (!b0.a(bArr2[y], (i - i4) + iArr[bArr2.length + y], bArr, i2, min)) {
                return false;
            }
            i += min;
            i2 += min;
            i3 -= min;
            y++;
        }
        return true;
    }

    public int p() {
        return this.g[this.f.length - 1];
    }

    public h t(int i, int i2) {
        return z().t(i, i2);
    }

    public String toString() {
        return z().toString();
    }

    public h u() {
        return z().u();
    }

    public byte[] v() {
        int[] iArr = this.g;
        byte[][] bArr = this.f;
        byte[] bArr2 = new byte[iArr[bArr.length - 1]];
        int length = bArr.length;
        int i = 0;
        int i2 = 0;
        while (i < length) {
            int[] iArr2 = this.g;
            int i3 = iArr2[length + i];
            int i4 = iArr2[i];
            System.arraycopy(this.f[i], i3, bArr2, i2, i4 - i2);
            i++;
            i2 = i4;
        }
        return bArr2;
    }

    public String w() {
        return z().w();
    }

    public void x(e eVar) {
        int length = this.f.length;
        int i = 0;
        int i2 = 0;
        while (i < length) {
            int[] iArr = this.g;
            int i3 = iArr[length + i];
            int i4 = iArr[i];
            v vVar = new v(this.f[i], i3, (i3 + i4) - i2, true, false);
            v vVar2 = eVar.a;
            if (vVar2 == null) {
                vVar.g = vVar;
                vVar.f = vVar;
                eVar.a = vVar;
            } else {
                vVar2.g.b(vVar);
            }
            i++;
            i2 = i4;
        }
        eVar.b += (long) i2;
    }

    public final int y(int i) {
        i = Arrays.binarySearch(this.g, 0, this.f.length, i + 1);
        return i >= 0 ? i : ~i;
    }

    public final h z() {
        return new h(v());
    }
}
